#include<bits/stdc++.h>
using namespace std;
#define int long long
vector<__int128> tc;
vector<pair<__int128,__int128> > vc;
int rm[100005];
__int128 eps=2,K=1;
int n,m,l,v,k;
void solve(){
    tc.clear(),vc.clear(),memset(rm,0x3f,sizeof(rm)),k=0;
    scanf("%lld %lld %lld %lld",&n,&m,&l,&v);
    for(int i=0;i<n;i++){
        int d,s,a;
        scanf("%lld %lld %lld",&d,&s,&a);
        if(a==0){
            if(s<=v)continue;
            else vc.push_back({K*d,K*l});
        }
        if(a>0){
            if(s>v)vc.push_back({K*d,K*l});
            if(s==v)vc.push_back({K*d+eps,K*l});
            if(s>=v)continue;
            __int128 tt=K*(v-s)/a;
            __int128 ts=tt*(v+s)/2+d*K;
            if(ts>=l*K)continue;
            vc.push_back({ts+eps,K*l});
        }
        if(a<0){
            if(s<=v)continue;
            __int128 tt=K*(v-s)/a;
            __int128 ts=tt*(v+s)/2+d*K;
            vc.push_back({K*d,min(K*l,ts-eps)});
        }
    }
    for(int i=0;i<m;i++){
        int x;
        scanf("%lld",&x);
        tc.push_back(K*x);
    }
    sort(tc.begin(),tc.end());
    rm[0]=0x3f3f3f3f;
    for(auto it:vc){
        int dl=lower_bound(tc.begin(),tc.end(),it.first)-tc.begin();
        int dr=upper_bound(tc.begin(),tc.end(),it.second)-tc.begin()-1;
        if(dr<dl)continue;
//        cout<<dl<<'-'<<dr<<endl;
        rm[dl]=min(rm[dl],dr),k++;
    }
    for(int i=m;~i;i--)rm[i]=min(rm[i],rm[i+1]);
    int ct=0,p=0;
    while(rm[p]<=m)
        ct++,p=rm[p]+1;
    cout<<k<<' '<<m-ct<<endl;
}
signed main(){
    for(int i=0;i<20;i++)K*=10;
    freopen("detect.in","r",stdin),freopen("detect.out","w",stdout);
    int T;
    cin>>T;
    while(T--)solve();
}
/*
1
5 5 15 3
0 3 0
12 4 0
1 1 4
5 5 -2
6 4 -4
2 5 8 9 15
*/
/*
diff detect1.out detect1.ans
diff detect2.out detect2.ans
diff detect3.out detect3.ans
diff detect4.out detect4.ans
diff detect5.out detect5.ans*/
